package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.WDayEnterWarehouseStat;
import com.ruoyi.statistic.service.IWDayEnterWarehouseStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日入库量Controller
 * 
 * @author wzy
 * @date 2024-09-01 17:36:31
 */
@RestController
@RequestMapping("/statistic/dayenter")
public class WDayEnterWarehouseStatController extends BaseController
{
    @Autowired
    private IWDayEnterWarehouseStatService wDayEnterWarehouseStatService;

    /**
     * 查询日入库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:list')")
    @GetMapping("/list")
    public TableDataInfo list(WDayEnterWarehouseStat wDayEnterWarehouseStat)
    {
        startPage();
        List<WDayEnterWarehouseStat> list = wDayEnterWarehouseStatService.selectWDayEnterWarehouseStatList(wDayEnterWarehouseStat);
        return getDataTable(list);
    }

    /**
     * 导出日入库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:export')")
    @Log(title = "日入库量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WDayEnterWarehouseStat wDayEnterWarehouseStat)
    {
        List<WDayEnterWarehouseStat> list = wDayEnterWarehouseStatService.selectWDayEnterWarehouseStatList(wDayEnterWarehouseStat);
        ExcelUtil<WDayEnterWarehouseStat> util = new ExcelUtil<WDayEnterWarehouseStat>(WDayEnterWarehouseStat.class);
        util.exportExcel(response, list, "日入库量数据");
    }

    /**
     * 获取日入库量详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:query')")
    @GetMapping(value = "/{dayEnterStatisticId}")
    public AjaxResult getInfo(@PathVariable("dayEnterStatisticId") Long dayEnterStatisticId)
    {
        return success(wDayEnterWarehouseStatService.selectWDayEnterWarehouseStatByDayEnterStatisticId(dayEnterStatisticId));
    }

    /**
     * 新增日入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:add')")
    @Log(title = "日入库量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WDayEnterWarehouseStat wDayEnterWarehouseStat)
    {
        wDayEnterWarehouseStat.setCreateBy(getNickName());
        return toAjax(wDayEnterWarehouseStatService.insertWDayEnterWarehouseStat(wDayEnterWarehouseStat));
    }

    /**
     * 修改日入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:edit')")
    @Log(title = "日入库量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WDayEnterWarehouseStat wDayEnterWarehouseStat)
    {
        wDayEnterWarehouseStat.setUpdateBy(getNickName());
        return toAjax(wDayEnterWarehouseStatService.updateWDayEnterWarehouseStat(wDayEnterWarehouseStat));
    }

    /**
     * 删除日入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayenter:remove')")
    @Log(title = "日入库量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dayEnterStatisticIds}")
    public AjaxResult remove(@PathVariable Long[] dayEnterStatisticIds)
    {
        return toAjax(wDayEnterWarehouseStatService.deleteWDayEnterWarehouseStatByDayEnterStatisticIds(dayEnterStatisticIds));
    }
}
